import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/file_list_entity.dart';

FileListEntity $FileListEntityFromJson(Map<String, dynamic> json) {
  final FileListEntity fileListEntity = FileListEntity();
  final String? dirName = jsonConvert.convert<String>(json['dirName']);
  if (dirName != null) {
    fileListEntity.dirName = dirName;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    fileListEntity.total = total;
  }
  final List<FileData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<FileData>(e) as FileData).toList();
  if (data != null) {
    fileListEntity.data = data;
  }
  return fileListEntity;
}

Map<String, dynamic> $FileListEntityToJson(FileListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['dirName'] = entity.dirName;
  data['total'] = entity.total;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  return data;
}

extension FileListEntityExtension on FileListEntity {
  FileListEntity copyWith({
    String? dirName,
    int? total,
    List<FileData>? data,
  }) {
    return FileListEntity()
      ..dirName = dirName ?? this.dirName
      ..total = total ?? this.total
      ..data = data ?? this.data;
  }
}

FileData $FileDataFromJson(Map<String, dynamic> json) {
  final FileData fileData = FileData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    fileData.id = id;
  }
  final String? caseId = jsonConvert.convert<String>(json['caseId']);
  if (caseId != null) {
    fileData.caseId = caseId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    fileData.name = name;
  }
  final int? fileId = jsonConvert.convert<int>(json['fileId']);
  if (fileId != null) {
    fileData.fileId = fileId;
  }
  final String? fileName = jsonConvert.convert<String>(json['fileName']);
  if (fileName != null) {
    fileData.fileName = fileName;
  }
  final int? deliveryType = jsonConvert.convert<int>(json['deliveryType']);
  if (deliveryType != null) {
    fileData.deliveryType = deliveryType;
  }
  final String? fileSize = jsonConvert.convert<String>(json['fileSize']);
  if (fileSize != null) {
    fileData.fileSize = fileSize;
  }
  final int? createdAt = jsonConvert.convert<int>(json['createdAt']);
  if (createdAt != null) {
    fileData.createdAt = createdAt;
  }
  return fileData;
}

Map<String, dynamic> $FileDataToJson(FileData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['caseId'] = entity.caseId;
  data['name'] = entity.name;
  data['fileId'] = entity.fileId;
  data['fileName'] = entity.fileName;
  data['deliveryType'] = entity.deliveryType;
  data['fileSize'] = entity.fileSize;
  data['createdAt'] = entity.createdAt;
  return data;
}

extension FileDataExtension on FileData {
  FileData copyWith({
    int? id,
    String? caseId,
    String? name,
    int? fileId,
    String? fileName,
    int? deliveryType,
    String? fileSize,
    int? createdAt,
  }) {
    return FileData()
      ..id = id ?? this.id
      ..caseId = caseId ?? this.caseId
      ..name = name ?? this.name
      ..fileId = fileId ?? this.fileId
      ..fileName = fileName ?? this.fileName
      ..deliveryType = deliveryType ?? this.deliveryType
      ..fileSize = fileSize ?? this.fileSize
      ..createdAt = createdAt ?? this.createdAt;
  }
}